package com.shioirikukuri.mapper;

import com.shioirikukuri.entity.ReservationDiningStatus;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ReservationDiningStatusMapper {

	/**
	 * 根据主键ID查询预订用餐状态信息
	 *
	 * @param id 主键ID
	 * @return 匹配的预订用餐状态对象
	 */
	@Select("SELECT * FROM reservation_dining_status WHERE id = #{id}")
	ReservationDiningStatus selectReservationDiningStatusById(@Param("id") Integer id);


	/**
	 * 查询所有预订用餐状态信息
	 *
	 * @return 预订用餐状态列表
	 */
	@Select("SELECT * FROM reservation_dining_status")
	List<ReservationDiningStatus> selectAllReservationDiningStatuses();

	/**
	 * 根据点餐订单ID查询状态信息
	 *
	 * @param diningOrderId 点餐订单ID
	 * @return 匹配的预订用餐状态列表
	 */
	@Select("SELECT * FROM reservation_dining_status WHERE dining_order_id = #{diningOrderId}")
	List<ReservationDiningStatus> selectByDiningOrderId(@Param("diningOrderId") Integer diningOrderId);

	/**
	 * 根据预约订单ID查询状态信息
	 *
	 * @param reservationOrderId 预约订单ID
	 * @return 匹配的预订用餐状态列表
	 */
	@Select("SELECT * FROM reservation_dining_status WHERE reservation_order_id = #{reservationOrderId}")
	List<ReservationDiningStatus> selectByReservationOrderId(@Param("reservationOrderId") Integer reservationOrderId);

	/**
	 * 插入新的预订用餐状态信息
	 *
	 * @param status 新的预订用餐状态信息
	 */
	@Insert({
			"INSERT INTO reservation_dining_status",
			"(dining_order_id, dining_order_status, reservation_order_id, reservation_order_status)",
			"VALUES",
			"(#{diningOrderId}, #{diningOrderStatus}, #{reservationOrderId}, #{reservationOrderStatus})"
	})
	@Options(useGeneratedKeys = true, keyProperty = "id")
	void insertReservationDiningStatus(ReservationDiningStatus status);

	/**
	 * 更新已有的预订用餐状态信息
	 *
	 * @param status 需要更新的状态信息
	 */
	@Update({
			"UPDATE reservation_dining_status SET",
			"dining_order_id = #{diningOrderId},",
			"dining_order_status = #{diningOrderStatus},",
			"reservation_order_id = #{reservationOrderId},",
			"reservation_order_status = #{reservationOrderStatus}",
			"WHERE id = #{id}"
	})
	void updateReservationDiningStatus(ReservationDiningStatus status);

	/**
	 * 删除指定ID的预订用餐状态记录
	 *
	 * @param id 记录ID
	 */
	@Delete("DELETE FROM reservation_dining_status WHERE id = #{id}")
	void deleteReservationDiningStatusById(@Param("id") Integer id);
}